<?PHP


function ShowFullScreenEditor ($objname, $window) {
        global $module_name;

        echo "<html>";
        echo "<head><title>"._FULLSCREENTITLE."</title>";
        echo "<style type='text/css'> body { margin: 0px; border: 0px; background-color: buttonface; } </style>";
        echo "<script>\n";
        // if we pass the "window" object as a argument and then set opener to
        // equal that we can refer to dialogWindows and popupWindows the same way
        echo "if (window.dialogArguments) {\n";
        echo "        opener = window.dialogArguments;\n";
        echo "}\n";
        echo "var _editor_url    = \"./modules/$module_name/\";\n";
        echo "document.write('<scr'+'ipt src=\"' +_editor_url+ 'editor.js\" language=\"Javascript1.2\"></scr'+'ipt>');\n";
        echo "var parent_objname = location.search.substring(1,location.search.length);\n";  // parent editor objname
        echo "var parent_config  = opener.document.all[\"". $objname ."\"].config;\n";
        echo "var config         = new cloneObject( parent_config );\n";
        echo "var objname        = 'editor';\n"; // name of this editor
        echo "function _CloseOnEsc() {\n";
        echo "        if (event.keyCode == 27) {\n";
        echo "                update_parent();\n";
        echo "                window.close();\n";
        echo "                return;\n";
        echo "        }\n";
        echo "}\n";
        echo "function cloneObject(obj) {\n";
        echo "        for (var n in obj) {\n";
        echo "                var node = obj[n];\n";
        echo "                if (typeof node == 'object') { this[n] = new cloneObject(node); }\n";
        echo "                else                         { this[n] = node; }\n";
        echo "        }\n";
        echo "}\n";
        echo "\n";
        echo "function resize_editor() {\n";                                                                                                                        // resize editor to fix window
        echo "        var editor          = document.all['_editor_editor'];\n";
        echo "        newWidth            = document.body.offsetWidth;\n";
        echo "        newHeight           = document.body.offsetHeight - editor.offsetTop;\n";
        echo "        if (newWidth < 0) { newWidth = 0; }\n";
        echo "        if (newHeight < 0) { newHeight = 0; }\n";
        echo "        editor.style.width  = newWidth;\n";
        echo "        editor.style.height = newHeight;\n";
        echo "}\n";
        echo "\n";
        echo "function init() {\n";
        // change maximize button to minimize button
        echo "        config.btnList[\"popupeditor\"] = ['popupeditor', '"._FULLSCREENMINIMIZE."', 'update_parent(); window.close();', 'ed_minimize.gif'];\n";
        // set htmlmode button to refer to THIS editor
        echo "        config.btnList[\"htmlmode\"]    = ['HtmlMode',    '"._FULLSCREENHTMLALT."' , 'editor_setmode(\'editor\')'      , 'ed_html.gif'];\n";
        echo "        config.imgURL = \"./modules/$module_name/images/\";\n";
        // generate editor and resize it
        echo "        editor_generate('editor', config);\n";
        echo "        resize_editor();\n";
        // switch mode if needed
        echo "        if (parent_config.mode == 'textedit') { editor_setmode(objname, 'textedit'); }\n";
        // set child window contents
        echo "        var parentHTML = opener.editor_getHTML(\"". $objname ."\");\n";
        echo "        editor_setHTML(objname, parentHTML);\n";
        // continuously update parent editor window
        echo "        window.setInterval(update_parent, 333);\n";
        // setup event handlers

        echo "        document.body.onkeypress = _CloseOnEsc;\n";
        echo "        window.onresize = resize_editor;\n";
        echo "}\n";
        echo "\n";
        echo "function update_parent() {\n";
        echo "        var childHTML = editor_getHTML(objname);\n";
        echo "        opener.editor_setHTML(\"". $objname ."\", childHTML);\n";
        echo "}\n";
        echo "\n";
        echo "</script>\n";

        echo "</head>";
        echo "<body scroll=no onload=\"init()\" onunload=update_parent()>";
        echo "<div style='margin: 0 0 0 0; border-width: 1; border-style: solid; border-color: threedshadow threedhighlight threedhighlight threedshadow; '></div>";
        echo "<textarea name=editor style='width:100%; height:300px'></textarea><br>";
        echo "</body></html>";
}

?>
